Skip to content

fix: use psycopg2 instead of psycopg2-binary to link against system libpq#369

Closed
vlsi wants to merge 1 commit intoNetcracker:mainfrom
vlsi:fix/psycopg2-libpq-version
Closed

fix: use psycopg2 instead of psycopg2-binary to link against system libpq#369
vlsi wants to merge 1 commit intoNetcracker:mainfrom
vlsi:fix/psycopg2-libpq-version

Conversation

@vlsi
Copy link
Copy Markdown
Collaborator

@vlsi vlsi commented Mar 28, 2026

psycopg2-binary bundles its own libpq 9.6, which does not support the target_session_attrs connection parameter (requires libpq >= 10).

This causes Patroni replicas to log errors every second:
psycopg2.ProgrammingError: invalid dsn: invalid connection option "target_session_attrs"

The error originates in Patroni's rewind.py check_leader_is_not_in_recovery(), which sets target_session_attrs='read-write' for PG >= 10.

Switching to psycopg2 (non-binary) compiles from source against the system's libpq-dev, which fully supports the parameter. libpq-dev is already present via the postgresql-server-dev dependency.

…ibpq

psycopg2-binary bundles its own libpq 9.6, which does not support the
target_session_attrs connection parameter (requires libpq >= 10).

This causes Patroni replicas to log errors every second:
  psycopg2.ProgrammingError: invalid dsn: invalid connection option "target_session_attrs"

The error originates in Patroni's rewind.py check_leader_is_not_in_recovery(),
which sets target_session_attrs='read-write' for PG >= 10.

Switching to psycopg2 (non-binary) compiles from source against the
system's libpq-dev, which fully supports the parameter.
libpq-dev is already present via the postgresql-server-dev dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vlsi vlsi added bug Something isn't working dependencies Pull requests that update a dependency file docker Pull requests that update docker code labels Mar 28, 2026
@vlsi vlsi closed this Mar 29, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2026
@vlsi vlsi deleted the fix/psycopg2-libpq-version branch March 29, 2026 15:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working dependencies Pull requests that update a dependency file docker Pull requests that update docker code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants